/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package Request;
import javax.swing.event.EventListenerList;
import java.util.*;

/**
 *
 * @author lcy
 */
public class RequestRdyUtil {
    private List<RequestReadyHandler> _r_rdy_handlers;

    public RequestRdyUtil(){
        _r_rdy_handlers = new ArrayList<RequestReadyHandler>();
    }

    public synchronized void addRequestReadyHandler( RequestReadyHandler l ) {
        _r_rdy_handlers.add( l );
    }

    public synchronized void removeRequestReadyHandler( RequestReadyHandler l ) {
        _r_rdy_handlers.remove( l );
    }

    public synchronized void _fireRequestReadyEvent(RequestRdyArg arg) {

        RequestResultReadyEvent request_ready =
                new RequestResultReadyEvent(this,arg);

        Iterator listeners = _r_rdy_handlers.iterator();

        while(listeners != null && listeners.hasNext() ) {
            RequestReadyHandler handler = ((RequestReadyHandler) listeners.next());
            handler.HandleResponse(request_ready);
        }
    }
}
